Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Online DDL: ensure high lock_wait_timeout in Vreplication cut-over #16601

Merged

Conversation

shlomi-noach
Copy link
Contributor

Description

Fixes #16591 by setting a high value for lock_wait_timeout in both cut-over sessions.

Related Issue(s)

#16591

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach shlomi-noach added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) labels Aug 15, 2024
Copy link
Contributor

vitess-bot bot commented Aug 15, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Aug 15, 2024
@shlomi-noach shlomi-noach removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 15, 2024
@shlomi-noach shlomi-noach requested a review from a team August 15, 2024 12:26
@github-actions github-actions bot added this to the v21.0.0 milestone Aug 15, 2024
@@ -1260,6 +1279,25 @@ func (e *Executor) initMigrationSQLMode(ctx context.Context, onlineDDL *schema.O
return deferFunc, nil
}

// initConnectionLockWaitTimeout sets the given locak_wait_timeout for the given connection, with a deferred value restoration function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lock is spelt wrong here (locak)

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 68.82%. Comparing base (be95882) to head (3d19e74).
Report is 5 commits behind head on main.

Files Patch % Lines
go/vt/vttablet/onlineddl/executor.go 0.00% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16601      +/-   ##
==========================================
- Coverage   68.83%   68.82%   -0.01%     
==========================================
  Files        1557     1558       +1     
  Lines      199983   200061      +78     
==========================================
+ Hits       137655   137694      +39     
- Misses      62328    62367      +39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@@ -578,6 +583,16 @@ func testScheduler(t *testing.T) {
assert.NotEmpty(t, rs.Rows)
})

t.Run("low @@lock_wait_timeout", func(t *testing.T) {
defer primaryTablet.VttabletProcess.QueryTablet("set global lock_wait_timeout=100000", keyspaceName, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this 100000 value come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some high value. Let me change that into something more official. One sec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now setting to actual original lock_wait_timeout.

// Set large enough `@@lock_wait_timeout` so that it does not interfere with the cut-over operation.
// The code will ensure everything that needs to be terminated by `migrationCutOverThreshold` will be terminated.
// Setting `lock_wait_timeout` here is done to just ensure MySQL does not interrupt prematurely. It is not
// done by means of ensuring cleanup/termination of operations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the It is not // done by means of ensuring cleanup/termination of operations. part is about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to explain that lock_wait_timeout has no role in the cut-over algorithm. It's not placed here so as to be part of the algorithm. We don't rely on MySQL to e.g. ensure proper rollback. The only reason we put it here is to ensure it is "higher than we'd run into".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove that whole sentence. The comment already says "The code will ensure ...", which is sufficient explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

go/vt/vttablet/onlineddl/executor.go Show resolved Hide resolved
func (e *Executor) initConnectionLockWaitTimeout(ctx context.Context, conn *connpool.Conn, lockWaitTimeout time.Duration) (deferFunc func(), err error) {
deferFunc = func() {}

if _, err := conn.Exec(ctx, `set @lock_wait_timeout=@@lock_wait_timeout`, 0, false); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but IMO slightly clearer to always use the return var. i.e. not use := here. Behavior is the same though either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would add clarity and intention to specify global here and a comment for those not super famiilar:

// Set a connection level SQL variable to the current global value.
set @lock_wait_timeout=@@global.lock_wait_timeout

Similar for the defer:

set @@session.lock_wait_timeout=@lock_wait_timeout

(we are using @@session already when we actually set it on line 1290)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but IMO slightly clearer to always use the return var. i.e. not use := here. Behavior is the same though either way.

My take is the opposite, I always find it more comfortable to be explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now using explicit @@session. at all places. In no place do I intend to use @@global.lock_wait_timeout. I'm reading the current session value, modify it, restoring it. I don't touch the global setting.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
// Set large enough `@@lock_wait_timeout` so that it does not interfere with the cut-over operation.
// The code will ensure everything that needs to be terminated by `migrationCutOverThreshold` will be terminated.
// Setting `lock_wait_timeout` here is done to just ensure MySQL does not interrupt prematurely. It is not
// done by means of ensuring cleanup/termination of operations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove that whole sentence. The comment already says "The code will ensure ...", which is sufficient explanation.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach shlomi-noach merged commit 44e48ca into vitessio:main Aug 18, 2024
129 checks passed
@shlomi-noach shlomi-noach deleted the onlineddl-set-lock-wait-timeout branch August 18, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
4 participants